package com.sample.generator.controller.impl;

import com.sample.generator.Generator;
import com.sample.generator.context.GenerationContext;
import com.sample.generator.context.GenerationContextProvider;
import com.sample.generator.controller.GeneratorController;

public class DefaultGeneratorController implements GeneratorController {

	private Generator generator;

	private GenerationContextProvider provider;

	public void setGenerator(Generator generator) {

		if (generator == null) {
			throw new IllegalArgumentException("Argument generator is null.");
		}
		this.generator = generator;
	}

	public void setGenerationContextProvider(GenerationContextProvider provider) {

		if (provider == null) {
			throw new IllegalArgumentException("Argument provider is null.");
		}
		this.provider = provider;
	}

	public void execute() {

		assert generator != null : "generator is null.";
		assert provider != null : "provider is null";

		GenerationContext[] contexts = provider.provideContexts();
		generator.generate(contexts);
	}
}
